package com.jing.system.comm.enums;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 性别
 * 		[m:男/f:女/n:未知]
 * @author jing.yue
 * @version 1.0
 * @since 2012-08-31
 */
public enum GenderType {
	/** 男 */
	TYPE_MAN("m", "男"),
	/** 女 */
	TYPE_WOMAN("f", "女"),
	/** 未知 */
	TYPE_UNKNOWN("n", "未知");

	private String code;

	private String text;

	public static Map<String, String> map;

	/**
	 * 根据Code获取对应的汉字
	 * @param code
	 * @return
	 */
	public static String getCodeByText(String code) {
		init();
		return map.get(code);
	}

	public static Map<String, String> getMap() {
		init();
		return map;
	}

	private GenderType(String code, String text) {
		this.code = code;
		this.text = text;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public static Map<String, String> init(){
		if(map == null){
			map = new LinkedHashMap<String, String>();
			map.put(TYPE_MAN.code, TYPE_MAN.text);
			map.put(TYPE_WOMAN.code, TYPE_WOMAN.text);
			map.put(TYPE_UNKNOWN.code, TYPE_UNKNOWN.text);
		}
		return map;
	}
}